class Resource::Token < ActiveRecord::Base
  set_table_name "resource_tokens"

  has_many :collections
  has_many :queries, :through => :collections

  def find_synonims
    temp_array = Array.new
    synonims = Resource::Synonim.find(:all, :conditions => ["token_id = ? OR synonim = ?", self.id, self.id])
    synonims.each do |x|
      temp_array << ((x.token_id == self.id) ? x.synonim : x.token_id)
    end

    Resource::Token.find(temp_array)
  end
end
